from flask import Flask
from app.config.settings import Config
from app.ext import register_ext
from app.config.logger import logging_conf


def create_app():
    """
        1.app = Flask(__name__) 创建app对象
        2.配置app.config
        3.app注册，db，jwt， 调用方法，ext.init.register_ext() 进行数据库的绑定，redis，jwt
        4、配置logger
        5、返回初始化的app
        6、注册蓝图对象
    """
    app = Flask(__name__)
    app.config.from_object(Config)  # 读取自定义的app.config配置项
    register_ext(app)  # 初始化db，jwt
    logging_conf(app)  # 配置logger日志

    return app


user_app = create_app()
from app.routes import regiter_blueprints
regiter_blueprints(user_app)  # 调用绑定方法
